<?php

function template_simplenetwork_above()
{
	global $context, $settings, $txt, $modSettings, $options, $scripturl;
	
	global $sourcedir;
	require_once($sourcedir . '/snet/Subs-SimpleNetwork-Post.php');
	require_once($sourcedir . '/Subs-Post.php');
	
	echo'
		<div id="snet_container">
			<div id="snet_profile_box">
				<span class="upperframe"><span></span></span>
				<div class="roundframe">
					<div class="cat_bar">
						<h3 class="catbg">
							', $context['member']['name'], '
							<span id="userstatus" class="floatright">', $context['can_send_pm'] ? '<a href="' . $context['member']['online']['href'] . '" title="' . $context['member']['online']['label'] . '" rel="nofollow">' : '', $settings['use_image_buttons'] ? '<img src="' . $context['member']['online']['image_href'] . '" alt="' . $context['member']['online']['text'] . '" align="middle" />' : $context['member']['online']['text'], $context['can_send_pm'] ? '</a>' : '','</span>
						</h3>
					</div>
					<div id="snet_profile_info">
						', $context['member']['avatar']['image'], '<br />
						<div class="snet_membergroup_info smalltext">
							', (!empty($modSettings['titlesEnable']) && !empty($context['member']['title']) ? $context['member']['title'] : ''), '<br />
							', (!empty($context['member']['group']) ? $context['member']['group'] : $context['member']['post_group']), '<br />
							', (!empty($context['member']['group_stars']) ? $context['member']['group_stars'] : ''), '
						</div>
						<ul class="reset snet_profile_icons">';

		// What about if we allow email only via the forum??
		if ($context['member']['show_email'] === 'yes' || $context['member']['show_email'] === 'no_through_forum' || $context['member']['show_email'] === 'yes_permission_override')
			echo '
							<li><a href="', $scripturl, '?action=emailuser;sa=email;uid=', $context['member']['id'], '" title="', $context['member']['show_email'] == 'yes' || $context['member']['show_email'] == 'yes_permission_override' ? $context['member']['email'] : '', '" rel="nofollow"><img src="', $settings['images_url'], '/email_sm.gif" alt="', $txt['email'], '" /></a></li>';

		// Don't show an icon if they haven't specified a website.
		if ($context['member']['website']['url'] !== '' && !isset($context['disabled_fields']['website']))
			echo '
							<li><a href="', $context['member']['website']['url'], '" title="' . $context['member']['website']['title'] . '" target="_blank" class="new_win">', ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/www_sm.gif" alt="' . $context['member']['website']['title'] . '" />' : $txt['www']), '</a></li>';

		// Are there any custom profile fields for the summary?
		if (!empty($context['custom_fields']))
		{
			foreach ($context['custom_fields'] as $field)
				if ($field['placement'] == 1 || empty($field['output_html']))
					echo '
							<li class="custom_field">', $field['output_html'], '</li>';
		}

		echo '
							', !isset($context['disabled_fields']['icq']) && !empty($context['member']['icq']['link']) ? '<li>' . $context['member']['icq']['link'] . '</li>' : '', '
							', !isset($context['disabled_fields']['msn']) && !empty($context['member']['msn']['link']) ? '<li>' . $context['member']['msn']['link'] . '</li>' : '', '
							', !isset($context['disabled_fields']['aim']) && !empty($context['member']['aim']['link']) ? '<li>' . $context['member']['aim']['link'] . '</li>' : '', '
							', !isset($context['disabled_fields']['yim']) && !empty($context['member']['yim']['link']) ? '<li>' . $context['member']['yim']['link'] . '</li>' : '', '
						</ul>';

		// Can they add this member as a buddy?
		if (!empty($context['can_have_buddy']) && !$context['user']['is_owner'])
			echo '
						<br /><a href="', $scripturl, '?action=buddy;u=', $context['id_member'], ';', $context['session_var'], '=', $context['session_id'], '">[', $txt['buddy_' . ($context['member']['is_buddy'] ? 'remove' : 'add')], ']</a>';

		echo '
						<p id="infolinks">';

		if (!$context['user']['is_owner'] && $context['can_send_pm'])
			echo '
							<a href="', $scripturl, '?action=pm;sa=send;u=', $context['id_member'], '">', $txt['profile_sendpm_short'], '</a> | ';
		echo '
							<a href="', $scripturl, '?action=profile;area=showposts;u=', $context['id_member'], '">', $txt['showPosts'], '</a> | 
							<a href="', $scripturl, '?action=profile;area=statistics;u=', $context['id_member'], '">', $txt['statPanel'], '</a>
						</p>';

	echo '
					</div>
				</div>
				<span class="lowerframe"><span></span></span>
				<br />
				<span class="upperframe"><span></span></span>
					<div class="roundframe">
						', ($context['can_edit_profile']) ? '<a href="' . $scripturl . '?action=profile;area=forumprofile;u=' . $context['member']['id'] . '" title="'.$txt['snet_edit_information'].'"><img src="'. $settings['default_images_url']. '/simplenetwork/edit.png" alt="'.$txt['snet_edit'].'" class="floatright" /></a>' : '', '
						<ul class="reset smalltext">';
						
		if ($context['user']['is_owner'] || $context['user']['is_admin'])
			echo'
							<li><strong>', $txt['username'], ':</strong> ', $context['member']['username'], '</li>';
		if (!isset($context['disabled_fields']['posts']))
			echo '					
							<li><strong>', $txt['profile_posts'], ':</strong> ', $context['member']['posts'] == 1337 ? 'leet' : $context['member']['posts'], ' (', $context['member']['posts_per_day'], ' ', $txt['posts_per_day'], ')</li>';
		if ($context['member']['show_email'] == 'yes')
			echo'
							<li><strong>', $txt['email'], ':</strong> <a href="', $scripturl, '?action=emailuser;sa=email;uid=', $context['member']['id'], '">', $context['member']['email'], '</a></li>';
		elseif ($context['member']['show_email'] == 'yes_permission_override')
			echo'
							<li><strong>', $txt['email'], ':</strong> <em><a href="', $scripturl, '?action=emailuser;sa=email;uid=', $context['member']['id'], '">', $context['member']['email'], '</a></em></li>';		
		if (!empty($context['member']['blurb']))
			echo'
							<li><strong>', $txt['personal_text'], ':</strong> ',$context['member']['blurb'],'</li>';
		if ($modSettings['karmaMode'] == '1')
			echo'
							<li><strong>', $modSettings['karmaLabel'], ':</strong> ', ($context['member']['karma']['good'] - $context['member']['karma']['bad']), '</li>';		
		elseif ($modSettings['karmaMode'] == '2')
			echo'
							<li><strong>', $modSettings['karmaLabel'], ':</strong> +', $context['member']['karma']['good'], '/-', $context['member']['karma']['bad'], '</li>';
		if (!isset($context['disabled_fields']['gender']) && !empty($context['member']['gender']['name']))
			echo'
							<li><strong>', $txt['gender'], ':</strong> ', $context['member']['gender']['name'], '</li>';	
			echo'
							<li><strong>', $txt['age'], ':</strong> ', $context['member']['age'] . ($context['member']['today_is_birthday'] ? ' &nbsp; <img src="' . $settings['images_url'] . '/cake.png" alt="" />' : ''), '</li>';	
		if (!isset($context['disabled_fields']['gender']) && !empty($context['member']['gender']['name']))
			echo'
							<li><strong>', $txt['location'], ':</strong> ', $context['member']['location'], '</li>';
						
		if (!empty($context['custom_fields']))
		{
			foreach ($context['custom_fields'] as $field)
			{
				if ($field['placement'] != 0 || empty($field['output_html']))
					continue;

				echo '
						<li><strong>', $field['name'], '</strong>: ', $field['output_html'], '</li>';
			}
		}	

	echo'
						</ul>
						<hr />
						<ul class="reset smalltext">';

	echo'
							<li><strong>', $txt['date_registered'], ':</strong> ', $context['member']['registered'], '</li>';
		if ($context['can_see_ip'])
		{
			if (!empty($context['member']['ip']))
			echo '
						<li><strong>', $txt['ip'], '</strong>: <a href="', $scripturl, '?action=profile;area=tracking;sa=ip;searchip=', $context['member']['ip'], ';u=', $context['member']['id'], '">', $context['member']['ip'], '</a></li>';

			if (empty($modSettings['disableHostnameLookup']) && !empty($context['member']['ip']))
				echo '
						<li><strong>', $txt['hostname'], ':</strong> ', $context['member']['hostname'], '</li>';
		}

			echo '
						<li><strong>', $txt['local_time'], ':</strong> ', $context['member']['local_time'], '</li>';

		if (!empty($modSettings['userLanguage']) && !empty($context['member']['language']))
			echo '
						<li><strong>', $txt['language'], ':</strong> ', $context['member']['language'], '</li>';

		echo '
						<li><strong>', $txt['lastLoggedIn'], ':</strong> ', $context['member']['last_login'], '</li>';							


		// Can they view/issue a warning?
		$shown = false;
		if ($context['can_view_warning'] && $context['member']['warning'])
		{
			echo'
						</ul>
					</div>
				<span class="lowerframe"><span></span></span>			
				<br />
				<span class="upperframe"><span></span></span>
					<div class="roundframe">
						<ul class="reset smalltext">';
			$shown = true;
						
			echo '
						<li><strong>', $txt['profile_warning_level'], ':</strong>
						<a href="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=', $context['can_issue_warning'] ? 'issuewarning' : 'viewwarning', '">', $context['member']['warning'], '%</a>';

			// Can we provide information on what this means?
			if (!empty($context['warning_status']))
				echo '
							<span class="smalltext">(', $context['warning_status'], ')</span>';

			echo '
						</li>';
		}

		// Is this member requiring activation and/or banned?
		if (!empty($context['activate_message']) || !empty($context['member']['bans']))
		{
			if(!$shown)
			echo'
						</ul>
					</div>
				<span class="lowerframe"><span></span></span>			
				<br />
				<span class="upperframe"><span></span></span>
					<div class="roundframe">
						<ul class="reset smalltext">';
		
			// If the person looking at the summary has permission, and the account isn't activated, give the viewer the ability to do it themselves.
			if (!empty($context['activate_message']))
				echo '
						<li><span class="alert">', $context['activate_message'], '</span>&nbsp;(<a href="' . $scripturl . '?action=profile;save;area=activateaccount;u=' . $context['id_member'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '"', ($context['activate_type'] == 4 ? ' onclick="return confirm(\'' . $txt['profileConfirm'] . '\');"' : ''), '>', $context['activate_link_text'], '</a>)</li>';

			// If the current member is banned, show a message and possibly a link to the ban.
			if (!empty($context['member']['bans']))
			{
				echo '
						<li><span class="alert">', $txt['user_is_banned'], '</span>&nbsp;[<a href="#" onclick="document.getElementById(\'ban_info\').style.display = document.getElementById(\'ban_info\').style.display == \'none\' ? \'\' : \'none\';return false;">' . $txt['view_ban'] . '</a>]</li>
						<li id="ban_info" style="display: none;">
							<strong>', $txt['user_banned_by_following'], ':</strong>';

				foreach ($context['member']['bans'] as $ban)
					echo '
							<br /><span class="smalltext">', $ban['explanation'], '</span>';

				echo '
						</li>';
			}
		}
		
	echo'
				</ul>
				</div>
				<span class="lowerframe"><span></span></span>
		</div>
		<div id="snet_wall">';
		
			if(!empty($context['snet_comment_errors']))
	echo'
		<div class="errorbox"',empty($context['snet_comment_errors']) ? ' style="display: none;"' : '','>
			',sprintf($txt['snet_error_notice_comment'],$_REQUEST['status']),'
		</div>';

	template_snet_status_update_form();
	
	echo'
			<div id="snet_wall_content">';
}

function template_simplenetwork_below()
{
	global $context, $settings, $txt, $modSettings, $options;
	
	echo'
		</div>';
			// Now we have the wall notes left to do.
	echo'
		<div id="snet_right_box">
			<div class="cat_bar grid_header" id="event_log">
				<h3 class="catbg">
					My Event Log
				</h3>
			</div>
			<ul id="snet_event_log" class="description reset">';
		
		if(empty($context['wall_notes']))
			echo'
				<li>There are no notes to show</li>';
		else
		{
			$current_note = 1;
			$num_notes = count($context['wall_notes']);
			$alt = false;
			foreach($context['wall_notes'] AS $event)
			{
				echo'
					<li class="snet_event_log_item ',$alt ? 'information' : 'description','" id="event',$event['id'],'">
						<span class="snet_delete_padding floatright">&nbsp;</span>', $context['can_delete'] ? '<a href="'.$event['delete'].'" onclick="return snet_delete_update(' . $event['id'] . ',' . JavaScriptEscape($txt['snet_confirm_delete_status_update']). ');" title="'.$txt['snet_delete'].'" id="snet_delete_'.$event['id'].'" style="display: none;"><img src="'. $settings['default_images_url']. '/simplenetwork/delete.png" alt="'.$txt['snet_delete'].'" class="floatright" width="12px;" /></a>' : '', '
							<img src="'.$settings['default_images_url'].'/simplenetwork/'.$event['note']['note_type'].'.png" alt="" class="floatleft" title="' . $event['real_date'] . '" />
							<div class="snet_event_body">', $context['member']['name'], ' ', $event['body'], '</div>
							
					</li>';
				
				$current_note++;
				$alt = !$alt;
			}
		}
			
	echo'
			</ul>
				<div class="titlebg smalltext snet_event_log_page_index">
					<div class="smalltext">
						<strong class="floatleft">',$txt['pages'],':</strong>
						',$context['events_page_index'],'
					</div>
			</div>
		</div>
		</div>
				<br class="clear" />
		</div>
		<span style="display: none;" id="snet" class="errorbox" />
	<script type="text/javascript">
		$(\'.snet_date\').each(function(){
			var date = $(this).attr(\'id\');
			var date = parseInt(date.replace(\'d_\',\'\')) * 1000;
			var date = new Date(date);
			var last_date = new Date()-3;
			if(date<last_date)
			$(this).countdown({since: date, significant: 1, layout: \'{d<}{dn} days {d>}{h<}{hn} hours {h>}{m<}{mn} minutes {m>}{s<}{sn} seconds{s>} ago\'}); 
		});
		$(\'textarea\').elastic();
		
		$(\'.snet_event_log_item\').hover(function(){
			var original = $(this).css("background-color");
			var color = $("#snet").css("background-color");
			$("#snet").css("background-color",original);
			$(this).css("background-color",color);
			var element = $(this).attr("id");
			var event = element.replace("event","");
			$("#snet_delete_" + event).show();
			$(this).children(".snet_delete_padding").hide();
		},function(){
			var original = $("#snet").css("background-color");
			var color = $(this).css("background-color");
			$(this).css("background-color",original);
			$("#snet").css("background-color",color);
			var element = $(this).attr("id");
			var event = element.replace("event","");
			$("#snet_delete_" + event).hide();		
			$(this).children(".snet_delete_padding").show();		
		});
		
		
var characters = ',$modSettings['snet_max_status_length'],';
$(".snet_form_character_limit").append(characters);
$(".snet_form_limited_field").keyup(function(){
        if($(this).val().length > characters){
        $(this).val($(this).val().substr(0, characters));
        }
    var remaining = characters -  $(this).val().length;
    $(".snet_form_character_limit").html(remaining);
    if(remaining <= 10)
    {
        $(".snet_form_character_limit").addClass(\'error\');
    }
    else
    {
        $(".snet_form_character_limit").removeClass(\'error\');
    }
    });

		var num_notes = 0;
		num_groups = 0;
		group = false;
		/*$(\'.snet_status\').each(function(){
			if($(this).hasClass(\'snet_status_note\'))
			{
				if(!group)
				{
					group = true;
					num_groups++;
				}
				num_notes++;

				if(num_notes > 2)
				{
					$(this).hide().addClass(\'snet_note_group\' + num_groups);
					$(\'#snet_num_notes_\' + num_groups).val("453535");
				}

				if(num_notes == 2)
				$(this).addClass(\'snet_see_more_holder\');
			}
			else
			{
				group = false;
				$(\'#snet_group_number\').removeAttr(\'id\');
				$(\'.snet_see_more_holder\').append(\'<div class="information snet_see_more_button"><a href="#snet_see_more\' + num_groups + \'" onclick="return snet_toggle_note_group(\' + num_groups + \');" id="snet_see_more\' + num_groups + \'">See <span id="snet_num_notes_\' + num_groups + \'">\' + num_notes + \'</span> more notes</a></div>\').removeAttr(\'id\');
				num_notes = 0;
			}
		});
		
		function snet_toggle_note_group(group)
		{
			$(\'.snet_note_group\' + group + \':hidden\').each(function(){
				$(this).show();
			});				
		}*/
		
		$("#snet_link").keyup(function(){
			var timeout = setTimeout("snet_read_link()",2000);
		}).keydown(function(){
			clearTimeout(timeout);
		});
		
		$(".snet_status").hover(function(){
			var element = $(this).attr("id");
			var status = element.replace("status","");
			$("#snet_delete_" + status).show();
		},function(){
			var element = $(this).attr("id");
			var status = element.replace("status","");
			$("#snet_delete_" + status).hide();
		});

		$(".snet_comment").hover(function(){
			var element = $(this).attr("id");
			var comment = element.replace("comment","");
			$("#snet_delete_comment_" + comment).show();
		},function(){
			var element = $(this).attr("id");
			var comment = element.replace("comment","");
			$("#snet_delete_comment_" + comment).hide();
		});		
		
		$(".snet_toggle_convo").show();
		',!empty($options['snet_enable_convo_mode']) ? 'snet_toggle_convo_mode(0);' : 'snet_toggle_convo_mode(1);','		
	</script>';
}

function template_status_update($status, $alt = false, $single_view = false)
{
	global $context, $settings, $txt, $modSettings, $scripturl, $user_info;
	
	echo'
				<div id="status', $status['id'] ,'" class="snet_status',$status['is_note'] ? ' snet_status_note' : '','"> 
				<div class="windowbg',$alt ? 2 : '','">
				<span class="topslice"><span></span></span>
				<div class="content">
					<div class="snet_poster_avatar floatleft">
						<a href="', $status['user']['href'], '" title="' ,$txt['profile_of'], ' ', $status['user']['name'], '">', $status['user']['avatar']['image'], '</a><br />
						',$status['is_note'] ? '<a title="'. $txt['snet_note_' . $status['note']['note_type'] . '_short'] . '"><img src="'.$settings['default_images_url'].'/simplenetwork/' . $status['note']['note_type'] . '.png" alt="'. $txt['snet_note_' . $status['note']['note_type'] . '_short'] . '" class="snet_post_type_icon" /></a>' : '<a title="'. $txt['snet_status_type_' . $context['status_update_types'][$status['type']]]. '"><img src="'.$settings['default_images_url'].'/simplenetwork/' . $context['status_update_types'][$status['type']] . '.png" alt="'. $txt['snet_status_type_' . $context['status_update_types'][$status['type']]]. '" class="snet_post_type_icon" /></a>','
					</div>
					<div class="snet_status_content">
						<div class="snet_status_body">
							', (($context['can_delete'] || $user_info['id'] == $status['user']['id'])) ? '<a href="'.$status['delete'].'" onclick="return snet_delete_update(' . $status['id'] . ',' . JavaScriptEscape($txt['snet_confirm_delete_status_update']). ');" title="'.$txt['snet_delete'].'" id="snet_delete_'.$status['id'].'" class="snet_delete"><img src="'. $settings['default_images_url']. '/simplenetwork/delete.png" alt="'.$txt['snet_delete'].'" class="floatright" /></a>' : '', '
							<strong>' .$status['user']['link']. '</strong>
							<span class="smalltext">
								', $status['body'],'
							</span>
						</div>
						<hr/>
					<div class="snet_status_actions smalltext">
						<span title="', $status['real_date'],'" id="d_', $status['timestamp'],'" class="snet_date">', $status['date'],'</span>';
					
					if($context['can_comment'])
						echo'
							| <a href="', $status['comment'], '" onclick="return snet_toggle_comment_form(', $status['id'], ',true);">',$txt['snet_comment'],'</a>';
							
					if($modSettings['snet_enable_dislike_buttons'] != 0 && $context['can_dislike'])
						echo'
							<span id="snet_dislike_button_',$status['id'],'"',isset($status['we_like']) ? ' style="display: none;"' : '','> | <a href="', $status['dislike'], '" onclick="return snet_dislike_status_update(', $status['id'], ',', $context['member']['id'], ',',isset($status['we_dislike']) ? 1 : 0,');">', isset($status['we_dislike']) ? $txt['snet_undislike'] : $txt['snet_dislike'],'</a></span>';

					if(!empty($modSettings['snet_enable_like_buttons']) && $context['can_like'])
						echo'
							<span id="snet_like_button_',$status['id'],'"',isset($status['we_dislike']) ? ' style="display: none;"' : '','> | <a href="', $status['like'], '" onclick="return snet_like_status_update(', $status['id'], ',', $context['member']['id'], ',', isset($status['we_like']) ? 1 : 0,');">', isset($status['we_like']) ? $txt['snet_unlike'] : $txt['snet_like'],'</a></span>';							
					
					if(!empty($status['note']['extra_link']))
						echo' | ',$status['note']['extra_link'],'';
						
					echo'
					</div>';
					
			// Tiiiiime foooor the LIKERS! (...and dislikers, in a bit)
			if(!empty($modSettings['snet_enable_like_buttons']))
			echo'
				<div class="description snet_likers"',empty($status['likers']) ? ' style="display: none;"' : '',' id="snet_likers_container_',$status['id'],'">
					<img src="', $settings['default_images_url'], '/simplenetwork/like.png" alt="" class="floatleft" />
					<span id="snet_likers_',$status['id'],'">';
			if(!empty($modSettings['snet_enable_like_buttons']) && !empty($status['likers']))
			{
				$num_total = count($status['likers']);
				$num_grabbed = 1;
				$shown_likers = array();
				// Grab the ones we're gonna show, max 3.
				foreach($status['likers'] AS $liker)
				{
					if($num_grabbed <= 3)
						$shown_likers[] = $liker['member']['link'];

					$num_grabbed++;
				}
				
				// Display them nicely.
				if (count($shown_likers) <= 2)
					echo implode(' ' . $txt['credits_and'] . ' ', $shown_likers);
				else
				{
					$last_peep = array_pop($shown_likers);
					echo implode(', ', $shown_likers), '',($num_total==3) ? ' ' . $txt['credits_and'] . ' ' : ', ','', $last_peep;
				}
				
				if($num_total > 3)
				echo $num_total == 4 ? sprintf($txt['snet_more_likers_single'],$status['id']) : sprintf($txt['snet_more_likers_multiple'],$status['id'],($num_total-3));

				echo $num_total == 1 ? $txt['snet_likes_this'] : $txt['snet_like_this'];						
			}
			
			echo'
				</span>
				</div>';
			
			// Dislikers
			if($modSettings['snet_enable_dislike_buttons'] != 0)
			echo'
				<div class="description snet_dislikers"',empty($status['dislikers']) ? ' style="display: none;"' : '',' id="snet_dislikers_container_',$status['id'],'">
					<img src="', $settings['default_images_url'], '/simplenetwork/dislike.png" alt="" class="floatleft" />
					<span id="snet_dislikers_',$status['id'],'">';			
			if($modSettings['snet_enable_dislike_buttons'] != 0 && !empty($status['dislikers']))
			{
				
				$num_total = count($status['dislikers']);
				
				// Are we showing names at all?
				if($modSettings['snet_enable_dislike_buttons'] == 1)
				{
					$num_grabbed = 1;
					$shown_dislikers = array();
					// Grab the ones we're gonna show, max 3.
					foreach($status['dislikers'] AS $disliker)
					{
						if($num_grabbed <= 3)
							$shown_dislikers[] = $disliker['member']['link'];
	
						$num_grabbed++;
					}
				
					// Display them nicely.
					if (count($shown_dislikers) <= 2)
						echo implode(' ' . $txt['credits_and'] . ' ', $shown_dislikers);
					else
					{
						$last_peep = array_pop($shown_dislikers);
						echo implode(', ', $shown_dislikers), '',($num_total==3) ? ' ' . $txt['credits_and'] . ' ' : ', ','', $last_peep;
					}
				
					if($num_total > 3)
					echo $num_total == 4 ? sprintf($txt['snet_more_likers_single'],$status['id']) : sprintf($txt['snet_more_likers_multiple'],$status['id'],($num_total-3));

					echo $num_total == 1 ? $txt['snet_dislikes_this'] : $txt['snet_dislike_this'];
				}
				else
				{
					echo $num_total;
					echo $num_total == 1 ? $txt['snet_anonymous_dislikes_single'] : $txt['snet_anonymous_dislikes_multiple'];		
				}	
			}
			
			echo'
				</span>
				</div>';
	
			if($single_view)
				echo'
					<span id="snet_num_comments" style="display: none;">',$status['num_comments'],'</span>
					<span id="snet_shown_comments" style="display: none;">',$status['num_comments'] > (!empty($_REQUEST['limit']) ? $_REQUEST['limit'] : 25) ? (!empty($_REQUEST['limit']) ? $_REQUEST['limit'] : 25) : $status['num_comments'], '</span>
					<div class="description snet_more_comments"',$status['num_comments'] > 25 ? '' : ' style="display: none;"',' id="snet_more_comments_',$status['id'],'">
						<a href="', sprintf($status['view_older'],$status['next_limit']), '" onclick="return snet_view_older_comments(',$status['id'],',',$context['member']['id'],');">
							<img src="', $settings['default_images_url'], '/expand.gif" alt="" class="floatleft" />&nbsp;
							',$txt['snet_view_more_comments'],'
						</a>
						<span class="floatright"><span id="snet_shown_comments_display">',!empty($_REQUEST['limit']) ? $_REQUEST['limit'] : 25,'</span> of ',$status['num_comments'],'</span>
					</div>';
			else
				echo'
					<div class="description snet_more_comments"',$status['num_comments'] > 2 ? '' : ' style="display: none;"',' id="snet_more_comments_',$status['id'],'">
						<a href="', $status['view_comments'], '" onclick="return snet_view_all_comments(',$status['id'],',',$context['member']['id'],');" id="snet_show_more_comments_link_',$status['id'],'">
							<img src="', $settings['default_images_url'], '/expand.gif" alt="" class="floatleft" />&nbsp;
							',sprintf($txt['snet_view_all_comments'],'<span id="snet_num_comments_'.$status['id'].'">'.$status['num_comments'].'</span>'),'
						</a>
						<a href="#snet_more_comments_',$status['id'],'" onclick="return snet_show_less(',$status['id'],');" id="snet_show_less_comments_link_',$status['id'],'" style="display: none;">
							<img src="', $settings['default_images_url'], '/collapse.gif" alt="" class="floatleft" />&nbsp;
							Show less
						</a>
					</div>';	
	
			echo'
					<div class="description snet_comments" id="comments', $status['id'], '"',empty($status['comments']) ? ' style="display: none;"' : '','>';
					
			// The comments (or the two latest, at least)
			if(!empty($status['comments']))
			{
				foreach($status['comments'] AS $comment)
				{
					echo'
						<div id="comment', $comment['id'],'" class="snet_comment">
						<div class="snet_poster_avatar_comment floatleft">
							<a href="', $comment['user']['href'], '" title="' ,$txt['profile_of'], ' ', $comment['user']['name'], '">', $comment['user']['avatar']['image'], '</a><br />
						</div>
						<div class="snet_comment_content" >
							<div class="snet_comment_body">
								', ($context['can_delete'] || $user_info['id'] == $comment['user']['id']) ? '<a href="'.$comment['delete'].'" onclick="return snet_delete_comment('.$comment['id'].','.$status['id'].',' . JavaScriptEscape($txt['snet_confirm_delete_comment']). ');" title="'. $txt['delete'] .'" id="snet_delete_comment_'.$comment['id'].'" class="snet_delete"><img src="'. $settings['default_images_url']. '/simplenetwork/delete.png" alt="'. $txt['delete'] .'" class="floatright" width="12px;" /></a>' : '', '
								<strong>', $comment['user']['link'], '</strong><br />
								<span class="smalltext">', $comment['body'],'</span>
							</div>
						<div class="snet_status_actions smalltext">
							<span title="', $comment['real_date'],'" id="d_', $comment['timestamp'],'" class="snet_date">', $comment['date'],'</span>';
							
						echo'
							<div class="snet_comment_likes">';
							
						if($modSettings['snet_enable_dislike_buttons'] != 0 && !empty($modSettings['snet_enable_dislike_buttons_comments']))
							echo'
							<a href="', $comment['dislike'],'" title="',(isset($comment['we_dislike']) ? $txt['snet_comment_you_dislike'] : $txt['snet_comment_dislike']),'" onclick="return snet_dislike_comment(',$comment['id'],',',$context['member']['id'],');"><img src="', $settings['default_images_url'], '/simplenetwork/dislike.png" class="snet_comment_dislike_icon" alt="',isset($comment['we_dislike']) ? 'Un-dislike' : 'Dislike','" /></a><a href="#comment_dislikers_', $comment['id'],'" class="snet_num_dislikes ',(isset($comment['we_dislike']) ? 'snet_we_like' : ''),'" id="snet_num_dislikers',$comment['id'],'">',count($comment['dislikers']),'</a>&nbsp;';
							
						if(!empty($modSettings['snet_enable_like_buttons']) && !empty($modSettings['snet_enable_like_buttons_comments']))
							echo'	
							<a href="', $comment['like'],'" title="' ,(isset($comment['we_like']) ? $txt['snet_comment_you_like'] : $txt['snet_comment_like']),'" onclick="return snet_like_comment(',$comment['id'],',',$context['member']['id'],');"><img src="', $settings['default_images_url'], '/simplenetwork/like.png" alt="',isset($comment['we_like']) ? 'Unlike' : 'Like','" /></a><a href="#comment_likers_', $comment['id'],'" class="snet_num_likes ',(isset($comment['we_like']) ? 'snet_we_like' : ''),'" id="snet_num_likers',$comment['id'],'">',count($comment['likers']),'</a>';					

					echo'
							</div>	
							</div>
						</div>
						<hr />
						</div>';
				}
			}
			
			echo'
				</div>';
			
			if($context['can_comment'])
			{
					
				echo'
					<div id="snet_status_comment_', $status['id'], '"', $status['num_comments'] > 0 || (!empty($context['snet_comment_errors']) && $_REQUEST['status'] == $status['id']) ? '' : ' style="display: none;"', ' class="description snet_comments">';
						
				echo'
					<div class="errorbox"',($_REQUEST['status'] == $status['id'] && !empty($context['snet_comment_errors']) ? '' : ' style="display: none;"'),' id="snet_comment_errors_',$status['id'],'">
						<ul class="reset" id="snet_comment_errors_ul_',$status['id'],'">';
				if($_REQUEST['status'] == $status['id'] && !empty($context['snet_comment_errors']))
				{						
					foreach($context['snet_comment_errors'] AS $error)
						echo'
								<li>',$txt['snet_error_' . $error],'</li>';
				}
				else
					echo'
						<li>&nbsp;</li>';
									
				echo'
						</ul>
					</div>';	
					
				echo'
						<div class="snet_poster_avatar_comment floatleft">
							', $context['user']['avatar']['image'], '
						</div>
						<div class="snet_comment_content">
							<form action="'.$context['canonical_url'].';status=', $status['id'],';sa=comment" method="post" class="snet_comment_body" onsubmit="return snet_post_comment(',$status['id'],',',$context['member']['id'],');" id="post_comment',$status['id'],'">
									<strong><a href="#">', $context['user']['name'], '</a></strong><br />
									<span class="smalltext">
										<textarea cols="50" rows="2" name="snet_comment', $status['id'],'" id="snet_comment_field_', $status['id'],'" style="width: 100%;" class="snet_comment_field">', !empty($_POST['snet_comment' . $status['id']]) ? $_POST['snet_comment' . $status['id']] : '','</textarea><br /><br />
										<input type="submit" value="',$txt['snet_post_comment'],'" id="snet_comment_submit_',$status['id'],'" class="snet_comment_submit" />
										<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
										<span class="floatright"><input type="checkbox" class="snet_toggle_convo snet_icon" value="1" checked="checked" onclick="return snet_toggle_convo_mode($(this).val());" id="snet_convo_mode_'.$status['id'].'" /> <label for="snet_convo_mode_'.$status['id'].'">Convo mode is <span class="snet_convo_mode_status"><strong>ON</strong>, hit enter to post</span></span>
									<br class="clear" /></span>
								</form>';
						
						echo'
							</div>
							<hr />';
						
					echo'
						</div>';	
				}
					
			echo'
					</div>
					<br class="clear" />	
				</div>
				<span class="botslice"><span></span></span>					
			</div>
			</div>';
}

function template_snet_main()
{
	global $context, $settings, $txt, $modSettings, $scripturl, $user_info;
	
	echo'
		<div id="snet_status_updates">';	
			
	if(empty($context['status_updates']))
		echo'
			<div class="windowbg" id="snet_no_status_updates">
				<span class="topslice"><span></span></span>
				<div class="content">
					',$txt['snet_no_status_updates'],'
				</div>
				<span class="botslice"><span></span></span>				
			</div>';
	else
	{
			
		$alt = false;
		foreach($context['status_updates'] AS $status)
		{
			template_status_update($status,$alt);
			$alt = !$alt;
		}
	}
	echo'
		</div>';	
}

function template_snet_view_status()
{
	global $context, $settings, $txt, $modSettings;

	echo'
		<div class="title_bar">
			<h3 class="titlebg">
				<a href="',$context['canonical_url'],'">
					<img src="',$settings['default_images_url'],'/simplenetwork/back.png" alt="" class="" />
					Back to ', $context['member']['name'],'\'s profile
				</a>
			</h3>
		</div>';
	
	template_status_update($context['status_update'],false,true);
}

function template_snet_status_update_form()
{
	global $context, $settings, $txt, $modSettings, $scripturl, $user_info;
	
	if($context['can_post'] && !empty($context['status_update_types']))
	{
		echo'
			<div class="errorbox" id="snet_status_update_errors"',empty($context['snet_errors']) ? ' style="display: none;"' : '','>
				<ul class="reset" id="snet_status_update_errors_ul">';
			
		if(!empty($context['snet_errors']))
		{
			foreach($context['snet_errors'] AS $error)
				echo'
						<li>',$txt['snet_error_' . $error],'</li>';
		}
		else
			echo'
						<li>&nbsp;</li>';		
						
		echo'
				</ul>
			</div>';						
		echo'
			<form action="',$scripturl,'?action=profile;u=',$context['member']['id'],';sa=post" method="post" class="information snet_status_update" enctype="multipart/form-data" id="snet_status_update" onsubmit="return snet_validate_status_update();">';
			
			// Text
			if(in_array(1,array_keys($context['status_update_types'])))
			echo'
				<div id="snet_status_update_text"',$context['status_update_type'] != 1 ? ' style="display: none;"' : 'class="snet_form_current_status_type"', '>
					<strong>',$txt['snet_status_update_text'],'</strong>
					<textarea rows="3" cols="100" style="width: 100%;" id="snet_message_box_1" name="snet_message" class="snet_form snet_form_limited_field">',!empty($_POST['snet_message']) ? $_POST['snet_message'] : '','</textarea>
					<span class="snet_form_character_limit catbg"></span>
				</div>';
			// Photo
			if(in_array(2,array_keys($context['status_update_types'])))	
			{			
				echo'
					<div id="snet_status_update_photo"',$context['status_update_type'] != 2 ? ' style="display: none;"' : 'class="snet_form_current_status_type"', '>
						<div class="buttonlist floatright"> 
							<ul> 
								<li><a class="button_strip_snet_photo_method1', $context['photo_method'] == 1 ? ' active' : '', '" href="',$context['canonical_url'],';status_type=2;photo_method=1;#snet_status_update" onclick="return snet_change_photo_method(1);"><span>',$txt['snet_photo_method_webcam'],'</span></a></li> 
								<li><a class="button_strip_snet_photo_method2', $context['photo_method'] == 2 ? ' active' : '', '" href="',$context['canonical_url'],';status_type=2;photo_method=2;#snet_status_update" onclick="return snet_change_photo_method(2);"><span>',$txt['snet_photo_method_upload'],'</span></a></li>
								<li><a class="button_strip_snet_photo_method3', $context['photo_method'] == 3 ? ' active' : '', '" href="',$context['canonical_url'],';status_type=2;photo_method=3;#snet_status_update" onclick="return snet_change_photo_method(3);"><span>',$txt['snet_photo_method_url'],'</span></a></li> 
							</ul> 
						</div>';
						
					// Webcam
					echo'
						<div class="snet_photo_method1"', $context['photo_method'] != 1 ? ' style="display: none;"' : '', '>
							<span id="snet_status_webcam_countdown"></span><br />
							<div id="snet_status_update_webcam"></div>
							<canvas id="snet_status_webcam_canvas"></canvas>
							<div id="snet_status_webcam_snap" class="titlebg">
								<img src="',$settings['default_images_url'],'/simplenetwork/webcam.png" class="snet_icon" alt="" />
								<a href="javascript:webcam.capture();void(0);">',$txt['snet_snap_photo'],'</a> &nbsp;&nbsp;&nbsp;&nbsp;  
								<img src="',$settings['default_images_url'],'/simplenetwork/delay.png" class="snet_icon" alt="" /> <a href="javascript:webcam.capture(3);void(0);">',$txt['snet_photo_delay'],'</a>
							</div>
							<br />
							<div id="snet_status_webcam_resnap" class="titlebg" style="display: none;">
								<img src="',$settings['default_images_url'],'/simplenetwork/scratch.png" class="snet_icon" alt="" />
								<a href="javascript:snet_retake_photo();">',$txt['snet_photo_scratch'],'</a>
							</div>
							<textarea name="webcam_data_string" id="snet_webcam_data_string" style="display: none;" cols="1" rows="1">',!empty($_POST['webcam_data_string']) ? $_POST['webcam_data_string'] : '','</textarea>
						</div>
							<script type="text/javascript"><!-- // --><![CDATA[
		var image = null;
var pos = 0;

var ctx = null;

var cam = null;
				
var cur_image_data = $("#snet_webcam_data_string").val();
	if(cur_image_data == \'\' || !cur_image_data)
 {	
		$("#snet_status_update_webcam").webcam({
        width: 320,
        height: 240,
        mode: "callback",
        swffile: "' . $settings['default_theme_url'] . '/scripts/snet_webcam/jscam_canvas_only.swf",
		onTick: function(remain) {
			if(remain == 0)
				$("#snet_status_webcam_countdown").html(\'<img src="',$settings['default_images_url'],'/simplenetwork/loading.gif" class="snet_icon" alt="" /> ',$txt['snet_photo_capturing'],'\');
			else
				$("#snet_status_webcam_countdown").html(\'<img src="',$settings['default_images_url'],'/simplenetwork/delay.png" class="snet_icon" alt="" /> \' + remain);
		},
        onSave: function(data) {
		
	$(\'#snet_status_webcam_canvas\').slideDown();
	$(\'#snet_status_update_webcam\').slideUp();
	$(\'#snet_status_webcam_snap\').hide();
	$(\'#snet_status_webcam_resnap\').show();

    var col = data.split(";");
    var img = image;

    for(var i = 0; i < 320; i++) {
        var tmp = parseInt(col[i]);
        img.data[pos + 0] = (tmp >> 16) & 0xff;
        img.data[pos + 1] = (tmp >> 8) & 0xff;
        img.data[pos + 2] = tmp & 0xff;
        img.data[pos + 3] = 0xff;
        pos+= 4;
    }

    if (pos >= 4 * 320 * 240) {
        ctx.putImageData(img, 0, 0);
        pos = 0;
    }

	var dataUrl = document.getElementById("snet_status_webcam_canvas").toDataURL();
	$("#snet_webcam_data_string").val(dataUrl);

	$("#snet_status_webcam_countdown").html(\'<img src="',$settings['default_images_url'],'/simplenetwork/done.png" class="snet_icon" alt="" /> ',$txt['snet_photo_captured'],'\');
},
        onCapture: function () {

        webcam.save();
},
        debug: function() {},
        onLoad: function() {}
});
}
else
{
	$("#snet_status_webcam_canvas").show();
}
window.addEventListener("load", function()
{
	var canvas = document.getElementById("snet_status_webcam_canvas");
	if (canvas.getContext) {
		ctx = document.getElementById("snet_status_webcam_canvas").getContext("2d");
		ctx.clearRect(0, 0, 320, 240);
		var img = new Image();
		img.src = cur_image_data;
		img.onload = function() {
			ctx.drawImage(img, 129, 89);
		}
		image = ctx.getImageData(0, 0, 320, 240);
	}
}, false);
function snet_retake_photo()
{
	$(\'#snet_status_webcam_canvas\').hide();
	$(\'#snet_status_update_webcam\').show();
	$(\'#snet_status_webcam_snap\').show();
	$(\'#snet_status_webcam_resnap\').hide();	
	$("#snet_status_webcam_countdown").html(\'\');
}

// ]]></script>';
				
					// Upload
					echo'
						<input class="snet_photo_method2 snet_image_file" type="file" name="snet_image_file"', $context['photo_method'] != 2 ? ' style="display: none;"' : '','', !empty($_POST['snet_image_file']) ? ' value="' . $_POST['snet_image_file'] . '"' : '',' /><br />';
					
					// URL Upload
					echo'
						<div class="snet_photo_method3"',$context['photo_method'] != 3 ? ' style="display: none;"' : '','>
							<strong>',$txt['snet_link_to_image'],'</strong> ',$txt['snet_http'],'
							<input type="text" name="snet_image_link" class="snet_image_link"', !empty($_POST['snet_image_link']) ? ' value="' . $_POST['snet_image_link'] . '"' : '',' size="70" id="snet_image_link"/><br />
						</div>';
					   
					echo'	
						<strong>',$txt['snet_caption'],'</strong> ',$txt['snet_optional'],'
						<textarea rows="3" cols="100" style="width: 100%;" id="snet_message_box_2" name="snet_caption" class="snet_form snet_form_limited_field">',!empty($_POST['snet_caption']) ? $_POST['snet_caption'] : '','</textarea>
						<span class="snet_form_character_limit catbg"></span>
						<input type="hidden" name="photo_method" value="', $context['photo_method'], '" id="snet_photo_method_hidden" />
					</div>';
			}
			// Link
			if(in_array(3,array_keys($context['status_update_types'])))
			echo'		
				<div id="snet_status_update_link"',$context['status_update_type'] != 3 ? ' style="display: none;"' : 'class="snet_form_current_status_type"', '>				
					<strong>',$txt['snet_url'],':</strong> ',$txt['snet_http'],' <input type="text" id="snet_link" name="snet_link"',!empty($_POST['snet_link']) ? ' value="' . $_POST['snet_link'] . '"' : '',' size="70" onchange="snet_link_title();"/><br />
					<strong>',$txt['snet_title'],':</strong> ',$txt['snet_optional'],' <input type="text" id="snet_link_title" name="snet_link_title"',!empty($_POST['snet_link_title']) ? ' value="' . $_POST['snet_link_title'] . '"' : '',' size="70"/><br />						
					<strong>',$txt['snet_status_update_poster_comment'],'</strong> ',$txt['snet_optional'],'
					<textarea rows="3" cols="100" style="width: 100%;" id="snet_message_box_3" name="snet_link_comment" class="snet_form snet_form_limited_field">',!empty($_POST['snet_link_comment']) ? $_POST['snet_link_comment'] : '','</textarea>
					<span class="snet_form_character_limit catbg"></span>
				</div>';	
			// Quote
			if(in_array(4,array_keys($context['status_update_types'])))
			echo'
				<div id="snet_status_update_quote"',$context['status_update_type'] != 4? ' style="display: none;"' : 'class="snet_form_current_status_type"', '>		
					<strong>',$txt['snet_quote'],'</strong>
					<textarea rows="3" cols="100" style="width: 100%;" id="snet_quote" name="snet_quote">',!empty($_POST['snet_quote']) ? $_POST['snet_quote'] : '','</textarea><br />
					<strong>',$txt['snet_source'],'</strong> ',$txt['snet_optional'],'
					<textarea rows="3" cols="100" style="width: 100%;" id="snet_quote_source" name="snet_quote_source">',!empty($_POST['snet_quote_source']) ? $_POST['snet_quote_source'] : '','</textarea><br />
					<strong>',$txt['snet_status_update_poster_comment'],'</strong> ',$txt['snet_optional'],'
					<textarea rows="3" cols="100" style="width: 100%;" id="snet_message_box_4" name="snet_quote_comment" class="snet_form snet_form_limited_field">',!empty($_POST['snet_quote_comment']) ? $_POST['snet_quote_comment'] : '','</textarea>
					<span class="snet_form_character_limit catbg"></span>
				</div>';
			// Video
			if(in_array(5,array_keys($context['status_update_types'])))
			echo'		
				<div id="snet_status_update_video"',$context['status_update_type'] != 5 ? ' style="display: none;"' : 'class="snet_form_current_status_type"', '>		
					<strong>',$txt['snet_link_to_video'],':</strong> ',$txt['snet_http'],' <input type="text" id="snet_video_link" name="snet_video_link"',!empty($_POST['snet_video_link']) ? ' value="' . $_POST['snet_video_link'] . '"' : '',' size="70"/><br />					
					<strong>Comment</strong> (optional)
					<textarea rows="3" cols="100" style="width: 100%;" id="snet_message_box_5" name="snet_video_comment" class="snet_form snet_form_limited_field">',!empty($_POST['snet_video_comment']) ? $_POST['snet_video_comment'] : '','</textarea>
					<span class="snet_form_character_limit catbg"></span>
				</div>';				

			echo'<br />
			
			<div id="snet_status_update_type">';
			
		foreach($context['status_update_types'] AS $num => $type)	
		{
			echo'
				<a href="',$context['canonical_url'],';status_type=' . $num . '#snet_status_update" title="', $txt['snet_status_type_' . $type], '" onclick="return snet_change_form_status_type(\'' . $type . '\',' . $num . ');"><img src="',$settings['default_images_url'],'/simplenetwork/' . $type . '.png" alt="', $txt['snet_status_type_' . $type], '" class="snet_status_update_form_icon description ',($context['status_update_type'] == $num ? 'snet_current_type' : ''),'" id="snet_status_update_form_icon_' . $num . '" /></a>';
		}

		echo'
			<a id="snet_post_help" href="',$scripturl,'?action=helpadmin;help=snet_post_help',$context['user']['is_owner'] ? '_own_profile' : '_other_profile','" onclick="return reqWin(this.href);" class="help snet_post_help" title="',$txt['help'],'"><img src="',$settings['images_url'],'/helptopics.gif" alt="',$txt['help'],'" /></a>
			</div>';	
			
		echo'
				<input type="submit" value="',$txt['snet_post_to_wall'],'" class="button_submit snet_submit_status" id="snet_status_update_submit" />
				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" id="snet_session" />
				<input type="hidden" name="snet_profile_id" id="snet_profile_id" value="', $context['member']['id'], '" />
				<input type="hidden" name="status_type" value="', $context['status_update_type'], '" id="snet_status_type_hidden" />
				<br class="clear" />
			</form>';
	}
}

?>